#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int jewelleryValue(vector<vector<int>>& nums) {
        int m = nums.size(), n = nums[0].size();
        vector<vector<int>> dp(m + 1, vector(n + 1, 0));
        for (int i = 1;i <= m;i++)
            for (int j = 1;j <= n;j++)
            {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]) + nums[i - 1][j - 1];
            }
        return dp[m][n];
    }
};